home *** CD-ROM | disk | FTP | other *** search
- /*
- File: CodeFragments.h
-
- Copyright: © 1984-1994 by Apple Computer, Inc.
- All rights reserved.
-
- Version: Universal Interfaces 2.0a1. ETO #15, MPW prerelease. Sunday, July 17, 1994.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
-
- #ifndef __CODEFRAGMENTS__
- #define __CODEFRAGMENTS__
-
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- /* #include <ConditionalMacros.h> */
-
- #ifndef __FILES__
- #include <Files.h>
- #endif
- /* #include <MixedMode.h> */
- /* #include <OSUtils.h> */
-
- #ifndef __TRAPS__
- #include <Traps.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if GENERATINGPOWERPC
- #pragma options align=mac68k
- #endif
-
- #ifdef __CFM68K__
- #pragma lib_export on
- #endif
-
- typedef long ConnectionID;
-
- typedef unsigned long LoadFlags;
-
- typedef unsigned char SymClass;
-
-
- enum {
- kPowerPCArch = 'pwpc', /* use as the architecture type */
- kMotorola68KArch = 'm68k', /* use as the architecture type */
- kAnyArchType = 0x3f3f3f3f,
- /* Confusing names, soon to be removed! */
- kPowerPC = 'pwpc', /* use as the architecture type */
- kMotorola68K = 'm68k', /* use as the architecture type */
- kNoLibName = 0,
- kNoConnectionID = 0,
- kUnresolvedSymbolAddress = 0
- };
-
- /* Constants used for findFlags mask */
- enum {
- kLoadLib = 1, /* use existing connection if possible */
- kFindLib = 2, /* just see if library is already loaded */
- kLoadNewCopy = 5, /* load a new instance no matter what */
- kUseInPlace = 0x80 /* use container’s sections in place */
- };
-
- enum {
- kCodeSym = 0,
- kDataSym = 1,
- kTVectSym = 2,
- kTOCSym = 3,
- kGlueSym = 4
- };
-
- /* Constants for the FragmentLocator field .where (other values for this enum exist) */
- enum {
- kInMem = 0,
- kOnDiskFlat = 1,
- kOnDiskSegmented = 2
- };
-
- #define IsFileLocation(where) (((where) == kOnDiskFlat) || ((where) == kOnDiskSegmented))
- enum {
- kIsLib = 0,
- kIsApp = 1,
- kIsDropIn = 2
- };
-
- /* Constants for the 'cfrg' field .updateLevel */
- enum {
- kFullLib = 0,
- kUpdateLib = 1
- };
-
- /* For fragment initialization routines */
- struct MemFragment {
- Ptr address;
- long length;
- Boolean inPlace;
- char spare3a[3];
- };
- typedef struct MemFragment MemFragment;
-
- struct DiskFragment {
- FSSpecPtr fileSpec; /* Must correspond to FSSpecPtr in segmented case */
- long offset;
- long length;
- };
- typedef struct DiskFragment DiskFragment;
-
- struct SegmentedFragment {
- FSSpecPtr fileSpec; /* Must correspond to FSSpecPtr in data fork case */
- OSType rsrcType;
- short rsrcID;
- };
- typedef struct SegmentedFragment SegmentedFragment;
-
- /* Note that the onDisk and inSegs members are required to have an FSSpecPtr
- field at the same location. CFM code uses just one member to access the
- information for either case */
- struct FragmentLocator {
- long where;
- union {
- MemFragment inMem;
- DiskFragment onDisk;
- SegmentedFragment inSegs;
- } u;
- };
-
- typedef struct FragmentLocator FragmentLocator, *FragmentLocatorPtr;
-
- /* NOTE: when fragLocator. where == kOnDisk, then
- fragLocator. u. onDisk. fileSpec is a pointer
- to the file that the library belonged to.
- the pointer is valid only for the duration
- of the init routine's invocation, so make
- a copy of the filespec if it is important */
- struct InitBlock {
- long contextID;
- long closureID;
- long connectionID;
- FragmentLocator fragLocator;
- Ptr libName;
- long reserved4a;
- long reserved4b;
- long reserved4c;
- long reserved4d;
- };
- typedef struct InitBlock InitBlock, *InitBlockPtr;
-
- /* Prototype for initialization routines. Note that these are C, not Pascal conventions!
- This differs from customary “Apple-callback” useage, but is felt to be less error prone
- in practice since the vast bulk of 68K CFM aware code will be in C.
- NOTE: Initialization routines may comfortably ignore their parameters, however, they must
- return an error status (ie: noErr) in order to succeed with the load of the library.
- Termination routines get no parameters and have no return value. */
- typedef OSErr ConnectionInitializationRoutine(InitBlockPtr initBlkPtr);
- typedef void ConnectionTerminationRoutine(void);
- /* Constants used in building shared libraries */
-
- enum {
- kCFMRsrcType = 'cfrg',
- kCFMRsrcID = 0,
- kSHLBFileType = 'shlb'
- };
-
- #ifndef TurnOff68KCFMTraps
- #define TurnOff68KCFMTraps 0
- #endif
- #if TurnOff68KCFMTraps
- extern pascal OSErr GetSharedLibrary(Str63 libName, OSType archType, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName);
- extern pascal OSErr GetDiskFragment(const FSSpec *fileSpec, long offset, long length, Str63 fragName, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName);
- extern pascal OSErr GetMemFragment(void *memAddr, long length, Str63 fragName, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName);
- extern pascal OSErr CloseConnection(ConnectionID *connID);
- extern pascal OSErr FindSymbol(ConnectionID connID, Str255 symName, Ptr *symAddr, SymClass *symClass);
- extern pascal OSErr CountSymbols(ConnectionID connID, long *symCount);
- extern pascal OSErr GetIndSymbol(ConnectionID connID, long symIndex, Str255 symName, Ptr *symAddr, SymClass *symClass);
- #else
- extern pascal OSErr GetSharedLibrary(Str63 libName, OSType archType, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName)
- THREEWORDINLINE(0x3F3C, 1, 0xAA5A);
- extern pascal OSErr GetDiskFragment(const FSSpec *fileSpec, long offset, long length, Str63 fragName, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName)
- THREEWORDINLINE(0x3F3C, 2, 0xAA5A);
- extern pascal OSErr GetMemFragment(void *memAddr, long length, Str63 fragName, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName)
- THREEWORDINLINE(0x3F3C, 3, 0xAA5A);
- extern pascal OSErr CloseConnection(ConnectionID *connID)
- THREEWORDINLINE(0x3F3C, 4, 0xAA5A);
- extern pascal OSErr FindSymbol(ConnectionID connID, Str255 symName, Ptr *symAddr, SymClass *symClass)
- THREEWORDINLINE(0x3F3C, 5, 0xAA5A);
- extern pascal OSErr CountSymbols(ConnectionID connID, long *symCount)
- THREEWORDINLINE(0x3F3C, 6, 0xAA5A);
- extern pascal OSErr GetIndSymbol(ConnectionID connID, long symIndex, Str255 symName, Ptr *symAddr, SymClass *symClass)
- THREEWORDINLINE(0x3F3C, 7, 0xAA5A);
- #endif
-
- #ifdef __CFM68K__
- #pragma lib_export off
- #endif
-
- #if GENERATINGPOWERPC
- #pragma options align=reset
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __CODEFRAGMENTS__ */
-